<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class JbUserMcard extends Model
{
    public $table = 'jbuser_mcard';

    public $timestamps=false;

    public $guarded = [];

    public function saleInfo()
    {
        return $this->hasMany(SaleInfo::class,'custno','card_no');
    }

    public function getCardTypeByCdmno($cdmno)
    {
//        解百卡12位，杭大卡10位，联名卡16位
        $length = strlen($cdmno);

        $card_type = [];
        dump($length);
        switch ($length){
            case '10':
                $card_type['p_hdcardno']=$cdmno;
                break;
            case '12':
                $card_type['p_oldcardno']=$cdmno;
                break;
            case '16':
                $card_type['p_lmcardno']=$cdmno;
                break;
        }

        return $card_type;
    }
}
